package com.xquant.trade.trade.mapper;

import com.xquant.trade.risk.entity.CombinedMonitorDetail;
import com.xquant.trade.trade.entity.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository("TradeMapper")
public interface TradeMapper {

    /*
    获取标的当天价格
     */
    Map<String, Object> getMarketPrice(Map<String, Object> param);

    /**
     * newCloud mapper 查询场内交易
     */
    List<InnerTrade> querySimpleTradeByPage(Map map);

    List<TradeGroupDTO> querysimpleTradeGroup(Map map);

    List<Trade> queryTradeByPage(Map map);

    List<Map> getICodePrice(Map map);

    List<Map> getICodeLastPrice(Map map);

    List<Map> getICodeInfo(Map map);

    List<Map> queryTradeInstrumentPrice(Map map);

    List<Map> queryTradeInstrumentPriceByDate(Map map);

    List<Map> queryTradeByStatus(Map map);

    List<Trade> queryTradeByMainTrade(Trade trade);

    List<Trade> queryTradeByAccount(Map map);

    List<Trade> queryTrade4OtcOptionByPage(Map map);

    List<Trade> queryTradeDuration4OtcOptionByPage(Map map);

    List<TradeDurationDTO> queryTradeDuration4OtcOptionBalanceByPage(Map map);

    List<Trade> queryTradeOption4OtcOptionByPage(Map map);

    TradeDetileDto queryTrade4OtcOptionForDetile(Map map);

    List<Trade> queryTrade4TrsByPage(Map map);

    TradeDetileDto queryTrade4TrsForDetile(Map map);

    List<Balance> queryBalanceByPage(Map map);

    List<Balance> queryBalanceByPage02(Map map);

    /**
     * newCloud 查询存续交易
     */
    List<Trade> queryGroupBalanceByPage(Map map);

    List<Balance> queryBalance4OtcOptionByPage(Map map);

    List<Trade> querySimpBalance4OtcOptionByPage(Map map);

    List<Balance> queryMonitorBalance4OtcOptionByPage(Map map);

    /**
     * newCloud 查询存续交易
     */
    List<Trade> queryTrade4OtcOptionDuration(Map map);

    List<Balance> querySceneBalance4OtcOptionByPage(Map map);


    List<Balance> queryBalance4TrsByPage(Map map);

    List<Trade> queryTradePByPage(Map map);

    List<Trade> queryTradeByEnd(Map map);

    Trade queryTradeById(String tradeId);
    Integer queryTradeVersionById(String tradeId);
    List<Balance> queryBalancePMAByPage(Map map);

    List<Balance> queryBalancePFIFOByPage(Map map);

    Map queryNational4Trs(Map map);

    void insertTrade(Trade trade);

    int updateTrade(Trade trade);

    /**
     * newCloud
     */
    void insertTequityDurationHis(CombinedMonitorDetail combinedMonitorDetail);

    /**
     * newCloud
     */
    void deleteTequityDuration(CombinedMonitorDetail combinedMonitorDetail);


    Long selectEquityDurationCount(CombinedMonitorDetail combinedMonitorDetail);

    /**
     * newCloud
     */
    void insertTequityDuration(CombinedMonitorDetail combinedMonitorDetail);


    void updateTradeStatus(Trade trade);

    void deleteTrade(Trade trade);

    void deleteAllTrade(Trade trade);

    List<BalanceChange> queryBalanceChange(Trade trade);

    void insertBalanceChange(BalanceChange change);

    void deleteBalanceChange(Trade trade);

    void insertTradeP(Trade trade);

    void updateTradeP(Trade trade);

    void updateTradePStatus(Trade trade);

    void deleteTradeP(Trade trade);

    void deleteAllTradeP(Trade trade);

    List<BalanceChange> queryBalanceChangeP(Trade trade);

    void insertBalanceChangeP(BalanceChange change);

    void deleteBalanceChangeP(Trade trade);

    List<Map> queryTradeContract(Map map);

    List<Trade> querySingleTradeContract(Map map);

    double queryTrsPL(Map map);

    List<Map> queryExpireContract(Map map);

    List<Map> queryExpireTradeList(Map map);

    List<Map> queryContractNoExpire(Map map);

    List<Map> queryTremind(Map map);

    List<Map> queryAllTremind();

    List<Map> query30DayTremind(Map map);

    void insertTremind(Map map);

    void updateTremind(Map map);

    void deleteTremind(Map map);

    String queryEventStatus(CombinedMonitorDetail detail);

    String queryEventStatusLast(CombinedMonitorDetail detail);

    List<Map> queryVdailyPrice(Map map);

    List<Map> queryVdailyPriceByDate(Map map);

    List<Map> queryTcalendarDates(Map map);

    List<Map> queryTcalendarLastDates(Map map);


    List<Map> queryTCalendar(Map map);

    List<Map> queryTCalendarDates(Map map);

    Map queryLastCalDay(Map map);

    void updateTCalendarDates(Map map);

    void updateTCalendarDatesByYear(Map map);

    void insertTCalendarDatesIfNotExist(Map map);

    void insertTCalendarDatesIfNotExistByYear(Map map);

    List<Trade> queryTodayExpireTrade4OtcOptionByPage(Map map);

    int queryTtradeCountByAccId(String accId);

    void updateTequityDuration(CombinedMonitorDetail detail);

    void removeAllEventStatus(Map map);

    void removeEventStatus(Map map);

    //获取需要传到summit1的交易的信息(交易编号和估值)
    List<Map> selectTranSummit(Map map);

    // 根据I_CODE查询TRADE_Version
    Map selectTradeVersionByICode(String iCode);

    void insertTradeVersion(Map<String, Object> versionMap);

    void updateTradeVersion(Map<String, Object> versionMap);

    List<Map> checkCalc(Map<String, Object> params);
}